package com.lin.missyou.core.configuration;

import com.lin.missyou.core.interceptors.PermissionInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author gcq
 * @Create 2021-11-01
 */
@Configuration
public class InterceptorConfiguration implements WebMvcConfigurer {

    /**
     * 注入到Spring容器
     * @return
     */
    @Bean
    public HandlerInterceptor gerPermissionInterceptor()
    {
        return new PermissionInterceptor();
    }
    /**
     * 添加拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(gerPermissionInterceptor());
    }
}